package com.cc2019.buke.user.Activity;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.cc2019.buke.R;
import com.cc2019.buke.user.Activity.address.AddressActivity;
import com.cc2019.buke.user.Activity.help.HelpActivity;

public class SuccessActivity extends AppCompatActivity implements View.OnClickListener{
    private String str="";
    private TextView tv_welcome;
    private Button setting;
    private Button address;
    private Button help_success;
    private Button shoucang;

    public Button changedark;
    public Button changeday;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_success);
        welcome();

        setting=(Button) findViewById(R.id.setting);
        setting.setOnClickListener(this);
        address=(Button) findViewById(R.id.address);
        address.setOnClickListener(this);
        help_success=(Button) findViewById(R.id.help_success);
        help_success.setOnClickListener(this);
        shoucang=(Button) findViewById(R.id.shoucang);
        shoucang.setOnClickListener(this);

        changedark=(Button) findViewById(R.id.night);
        changeday=(Button) findViewById(R.id.daytime);
        changeday.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_NO);
                recreate();
            }
        });
        changedark.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES);
                recreate();
            }
        });

    }

    private void welcome(){
        Intent intent=getIntent();//获取intent
        //获取intent中名为username的数据
        String username=intent.getStringExtra("username");
        Log.e("TAG", "welcome: "+ username);
        tv_welcome=findViewById(R.id.tv_welcome);
        str=String.format("%s",username);
        tv_welcome.setText(str);

    }
    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.setting:
                Intent intent=new Intent(SuccessActivity.this,SettingActivity.class);
                startActivity(intent);
                break;
            case R.id.address:
                Intent intent1=new Intent(SuccessActivity.this, AddressActivity.class);
                startActivity(intent1);
                break;
            case R.id.help_success:
                Intent intent2=new Intent(SuccessActivity.this, HelpActivity.class);
                startActivity(intent2);
                break;
            case R.id.shoucang:
                Intent intent3=new Intent(SuccessActivity.this, ShoucangActivity.class);
                startActivity(intent3);
                break;
        }
    }

}